package cn.uikit.demo.dialog

import android.content.Context
import android.content.Intent
import android.graphics.Color
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import cn.uikit.demo.R
import cn.uikit.demo.databinding.ActivityDialogTestBinding
import sivin.uikit.dialog.UkBottomSheet
import sivin.uikit.framework.BindingActivity
import sivin.uikit.utils.dp

class DialogTestActivity :
    BindingActivity<ActivityDialogTestBinding>(ActivityDialogTestBinding::inflate) {

    companion object {
        fun launch(context: Context) {
            val startIntent = Intent(context, DialogTestActivity::class.java)
            context.startActivity(startIntent)
        }
    }

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        binding.supperBottomSheet.setOnClickListener {
            val dialog = DialogFragment()
            dialog.show(supportFragmentManager, "test_dialog")
        }
    }

    class DemoBottomSheetFragment : UkBottomSheet() {
        override fun getContentView(inflater: LayoutInflater, container: ViewGroup?): View {
            return inflater.inflate(R.layout.demo_sheet, container, false)
        }

        override fun getCornerRadius() =
            requireContext().resources.getDimension(R.dimen.demo_sheet_rounded_corner)

        override fun getStatusBarColor() = Color.argb(0x00, 0xFF, 0x00, 0x00)

        override fun getPeekHeight(): Int {
            return 200f.dp
        }
    }
}